
#include "delay.h"

void Delay_Us(u32 microsecond)
{
    u32 temp;
    SysTick->LOAD = 9 * microsecond;
    SysTick->VAL = 0X00; //clear
    SysTick->CTRL = 0X01; //SysTick enable
    do
    {
        temp = SysTick->CTRL; 
    }
    while((temp & 0x01) && (!(temp & (1 << 16)))); 
    SysTick->CTRL = 0x00; 
}

void Delay_Ms(u32 millisecond)
{
    u32 temp;
    SysTick->LOAD = 9000 * millisecond;
    SysTick->VAL = 0X00; 
    SysTick->CTRL = 0X01; //SysTick enable
    do
    {
        temp = SysTick->CTRL;
    }
    while((temp & 0x01) && (!(temp & (1 << 16))));
    SysTick->CTRL = 0x00; 
}


/*** http://www.eeboard.com/bbs/thread-3473-1-1.html **/
